# Multi-target makefile
# http://www.gnu.org/software/make/manual/make.html

# CC and CFLAGS specify the C compiler and its flags, respectively. 
# CXX and CXXFLAGS specify the C++ compiler and its flags.

# $* -- file name part of current dependent (minus .suffix). 
# $@ -- full target name of current target. 
# $< -- .c file of target.

CC = gcc
CFLAGS = -O2 -g -Wall -Iinclude

# Object files (Ending in .o, 
# these are compiled from .c files by make)
OBJS = refChar.o wordPages.o ystr.o ysortedList.o ylinkedList.o yoneWayList.o \
  yinteger.o yhtml.o yarray2D.o ypropertiesFile.o
OBJS_FILES = o/refChar.o o/wordPages.o o/ystr.o o/ysortedList.o o/ylinkedList.o o/yoneWayList.o \
  o/yinteger.o o/yhtml.o o/yarray2D.o o/ypropertiesFile.o

clean:
	rm -f o/*.o tmp_make
	(cd lib/tool; make clean)
	(cd lib/mkindex; make clean)

dep:
#	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
#	(for i in lib/*.c;do echo -n "lib/";$(CPP) -M $$i;done) >> tmp_make
#	cp tmp_make Makefile
	(cd lib/tool; make dep)
	(cd lib/mkindex; make dep)

test: test.o $(OBJS)
	$(CC) $(CFLAGS) o/test.o $(OBJS_FILES) -o bin/test

in: mkindex.o $(OBJS)
	$(CC) $(CFLAGS) o/mkindex.o $(OBJS_FILES) -o bin/z_mkindex

mkindex.o:
	$(CC) $(CFLAGS) -c lib/mkindex.c -o o/mkindex.o
test.o:
	$(CC) $(CFLAGS) -c lib/test.c -o o/test.o

refChar.o:
	$(CC) $(CFLAGS) -c lib/mkindex/refChar.c -o o/refChar.o
wordPages.o:
	$(CC) $(CFLAGS) -c lib/mkindex/wordPages.c -o o/wordPages.o
ysortedList.o:
	$(CC) $(CFLAGS) -c lib/tool/ysortedList.c -o o/ysortedList.o
ylinkedList.o:
	$(CC) $(CFLAGS) -c lib/tool/ylinkedList.c -o o/ylinkedList.o
yoneWayList.o:
	$(CC) $(CFLAGS) -c lib/tool/yoneWayList.c -o o/yoneWayList.o
ystr.o:
	$(CC) $(CFLAGS) -c lib/tool/ystr.c -o o/ystr.o
yinteger.o:
	$(CC) $(CFLAGS) -c lib/tool/yinteger.c -o o/yinteger.o
yhtml.o:
	$(CC) $(CFLAGS) -c lib/tool/yhtml.c -o o/yhtml.o
yarray2D.o: 
	$(CC) $(CFLAGS) -c lib/tool/yarray2D.c -o o/yarray2D.o
ypropertiesFile.o:
	$(CC) $(CFLAGS) -c lib/tool/ypropertiesFile.c -o o/ypropertiesFile.o

### Dependencies:
